package com.usian.article.controller;

import com.usian.article.ArticleHomeControllerApi;
import com.usian.article.service.ArticleHomeService;
import com.usian.common.constants.article.ArticleConstans;
import com.usian.model.article.dtos.ArticleHomeDto;
import com.usian.model.common.dtos.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/api/v1/home")
public class ArticleHomeController implements ArticleHomeControllerApi {

    @Autowired
    private ArticleHomeService articleHomeService;

    @Override
    @PostMapping("/load")
    public ResponseResult load(@RequestBody ArticleHomeDto dto) {
        return articleHomeService.load(dto, ArticleConstans.LOADTYPE_LOAD_MORE);
    }

    @Override
    @PostMapping("/load_more")
    public ResponseResult loadMore(@RequestBody ArticleHomeDto dto) {
        return articleHomeService.load(dto, ArticleConstans.LOADTYPE_LOAD_MORE);
    }

    @Override
    @PostMapping("/load_new")
    public ResponseResult loadNew(@RequestBody ArticleHomeDto dto) {
        return articleHomeService.load(dto, ArticleConstans.LOADTYPE_LOAD_NEW);
    }

}
